package com.example.common.domain.pojo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.Data;

import java.io.Serializable;
import java.sql.Timestamp;
import java.time.Instant;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

@Data
@Entity
@Table(name = "homework")
public class Homework  {
    @Id
    @TableId(type = IdType.ASSIGN_UUID)
    private String id;
    private String courseId;
    private String classId;
    private String teacherId;
    private String homeworkName;
    private Timestamp startTime;   //开始时间
    private Timestamp updateTime;   //结束时间
    private Integer status;   //0为  未结束   1 为已结束

//    // 可选：添加setter时的类型转换逻辑
//    public void setStartTime(String startTimeStr) {
//        if (startTimeStr != null) {
//            // 将"YYYY-MM-DD"字符串转为LocalDate，再转Timestamp
//            LocalDate localDate = LocalDate.parse(startTimeStr, DateTimeFormatter.ISO_LOCAL_DATE);
//            this.startTime = Timestamp.valueOf(localDate.atStartOfDay());
//        }
//    }
//
//    public void setUpdateTime(Long updateTimeStamp) {
//        if (updateTimeStamp != null) {
//            // 将时间戳转为Instant，再转Timestamp
//            Instant instant = Instant.ofEpochSecond(updateTimeStamp);
//            this.updateTime = Timestamp.from(instant);
//        }
//    }


}
